#!/bin/bash
#Send to MP3 Player by Storm Dragon
#in order for this cript to work, you must have sox installed and it must be
#able to write mp3 files.
#There is a small guide for accomplishing this at:
#http://stormdragon.us/?p=118
#installPath = ~/.gnome2/nautilus-scripts/Send\ to\ MP3\ Player
#Set playerPath to the path of your mp3 player
playerPath=$(zenity --file-selection --directory --filename "/media/" --title "Send to MP3 Player - select Your Player")
if [ ! -d $playerPath ] ; then
zenity --error --text="MP3 player not found. Please make sure the device is connected and the path is correct."
exit 1
fi
#get a rough estimate for percent incrementer
counter=$((100 / $#))
#initialize percent value to 0
percent=0
#main loop that handles audio conversion and placement
(while [ $# -gt 0 ]; do
#increment the percent for the progress bar
percent=$(($percent + $counter))
#send percent information to the progress bar
echo "$percent"
#Get name of current track
music="$1"
#Get the name of the new mp3 track
mp3=`basename "$music" | sed 's/\.\w*$/.mp3/'`
#convert the track to mp3. Sox needs to be compiled from scratch for this to work with mp3 support
sox "$music" "$playerPath/$mp3"
#Speak last completed track.
espeak -v en-us "$mp3 complete."
#If there are no tracks left make sure percent is set to 100 so the dialog will close
if [ $# -eq 1 ] ; then
percent=100
fi
shift
done) | zenity --progress --auto-close --auto-kill --pulsate --text="Converting and Transferring tracks"
exit 0
